package com.youlian.cloud.system.config;

import com.youlian.cloud.common.config.CommonConfig;
import com.youlian.cloud.common.feign.config.FeignConfigBean;
import com.youlian.cloud.core.config.SpringMvcConfig;
import com.youlian.cloud.core.config.SwaggerConfigBean;
import com.youlian.cloud.log.asepct.LogResponseBodyAdvice;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author liuhx
 * @create 2019/08/01 17:26
 * @email liuhx@elab-plus.com
 **/
@Configuration
@EnableWebMvc
@EnableSwagger2
@ConfigurationProperties(prefix = "swagger2")
@ComponentScan(basePackages = {"com.youlian.cloud.system.service.impl"}, includeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION, value = {Controller.class})})
@Import({SpringMvcConfig.class, SwaggerConfigBean.class, LogResponseBodyAdvice.class
        ,FeignConfigBean.class
})
public class MvcConfigBean extends CommonConfig {

    @Bean(name = "multipartResolver")
    public MultipartResolver getCommonsMultipartResolver() {
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        multipartResolver.setMaxUploadSize(10485760);
        multipartResolver.setDefaultEncoding("UTF-8");
        return multipartResolver;
    }
}
